from django.conf.urls.defaults import *
from django.contrib.auth.views import login, logout
from django.conf import settings
from django.contrib import admin
admin.autodiscover()

from pypsqueak.artifact.models import Artifact
from pypsqueak.group.models import Group, Assignment
from pypsqueak.profile.models import *

urlpatterns = patterns('',
	# Admins
		(r'^admin/doc/', include('django.contrib.admindocs.urls')),
		(r'^admin/(.*)', admin.site.root),

	# Credits & Lic files
		 (r'^credits.html$', 'django.views.static.serve', {'document_root': 'c:/Python25/pypsqueak/files/credits.html'}),

	# Custom CSS
		 (r'^base.css$', 'pypsqueak.chrome.views.base_css'),
		 (r'^(?P<type>[a-zA-Z]+).(?P<pk>[0-9]+).css$', 'pypsqueak.chrome.views.profile_css'),

	# Root Page & CSS
	(r'^$', 'pypsqueak.page.views.site_index'),

	# Log in / out
	(r'^accounts/login/$',  login),
	(r'^accounts/logout/$', logout),

	# Comment
	(r'^comments/', include('django.contrib.comments.urls')),
)

# Profiles application
urlpatterns += patterns('pypsqueak.profile.views',
	(r'^profile/$','list'),
	(r'^(?P<username>[a-zA-Z0-9]+)/profile/$','read'),
	(r'^(?P<username>[a-zA-Z0-9]+)/profile/update/$','update'),
)

# Group Application.
urlpatterns += patterns('pypsqueak.group.views',
	(r'^group/membership/insert/$','membership_insert'),
	(r'^group/assignment/insert/$','assignment_insert'),
	(r'^group/assignment/(?P<assignment_id>[0-9]+)/update/$','assignment_update'),
	(r'^group/assignment/(?P<assignment_id>[0-9]+)/delete/$','assignment_delete'),
	(r'^group/assignment/(?P<assignment_id>[0-9]+)/$','assignment_read'),
	(r'^group/$', 'group_list'),
	(r'^group/insert/$','group_insert'),
	(r'^group/(?P<group_slug>[a-zA-Z0-9\-]+)/update/$','group_update'),
	(r'^group/(?P<group_slug>[a-zA-Z0-9\-]+)/delete/$','group_delete'),
	(r'^group/(?P<group_slug>[a-zA-Z0-9\-]+)/$','group_read'),
)

# Portfolio application
urlpatterns += patterns('pypsqueak.page.views',
	(r'^(?P<username>[a-zA-Z0-9]+)/$', 'page_list'),
	(r'^(?P<username>[a-zA-Z0-9]+)/page/(?P<slug>.*)/artifact/$','pageartifact_list'),
	(r'^(?P<username>[a-zA-Z0-9]+)/page/(?P<slug>.*)/(?P<id>[0-9]+)/annotate/$','pageartifact_annotate'),
	(r'^(?P<username>[a-zA-Z0-9]+)/page/(?P<slug>.*)/(?P<id>[0-9]+)/$','pageartifact_read'),
	(r'^(?P<username>[a-zA-Z0-9]+)/page/(?P<slug>.*)/artifact/insert/$','pageartifact_insert'),
	(r'^(?P<username>[a-zA-Z0-9]+)/page/(?P<slug>.*)/artifact/(?P<id>[0-9]+)/update/$','pageartifact_update'),
	(r'^(?P<username>[a-zA-Z0-9]+)/page/(?P<slug>.*)/artifact/(?P<id>[0-9]+)/delete/$','pageartifact_delete'),
	(r'^(?P<username>[a-zA-Z0-9]+)/page/insert/$','page_insert'),
	(r'^(?P<username>[a-zA-Z0-9]+)/page/(.*)/insert/$','page_insert'),
	(r'^(?P<username>[a-zA-Z0-9]+)/page/(?P<slug>.*)/update/$','page_update'),
	(r'^(?P<username>[a-zA-Z0-9]+)/page/(?P<slug>.*)/delete/$','page_delete'),
	(r'^(?P<username>[a-zA-Z0-9]+)/page/(?P<slug>.*)/$','page_read'),
)

urlpatterns += patterns('pypsqueak.artifact.views',
)

# Setting to enable file serving while in debug mode (aka, development).  Not for production.
if settings.DEBUG:
		urlpatterns += patterns('',
				(r'^files/(?P<path>.*)$', 'django.views.static.serve', {'document_root': 'c:/Python25/pypsqueak/files/'}),
		)
